//package com.tinshow.web.httpclient;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import org.apache.poi.hssf.usermodel.*;
//import org.apache.poi.hssf.util.HSSFColor;
//
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.util.*;
//
///**
// * Created by randy on 16-12-8.
// */
//public class Category {
//
//    private static List<String> list = null;
//
//    private static List<String> list1 = null;
//
////    public static void main(String[] args) {
////        try {
////            BufferedReader reader1 = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/home/randy/cate.txt"))));
////            StringBuffer sb1 = new StringBuffer();
////            String text1 = null;
////            while ((text1 = reader1.readLine()) != null) {
////                sb1.append(text1);
////            }
////            File file = new File("/home/randy/rele.txt");
////            FileInputStream fis = new FileInputStream(file);
////            InputStreamReader read = new InputStreamReader(fis);
////            BufferedReader reader = new BufferedReader(read);
////            String text = null;
////            StringBuffer sb = new StringBuffer();
////            while ((text = reader.readLine()) != null) {
////                sb.append(text);
////            }
////            read.close();
//////            Map<String, String> map = parsecate(sb1.toString(), sb.toString());
////            List<String> list = parsecate(sb1.toString(), sb.toString());
////            List<String> list1 = parsecate2(list,sb.toString());
//////            System.out.print(map);
//////            Map<String,String> map1 = parsecate1(map,sb.toString());
//////            parseJs(sb.toString());
//////            getExcel(map,map1);
//////            getExport(map);
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
////
////    }
//
//    public static String parseJs(String text) {
//        for (int i = 0; i < text.split(";").length; i++) {
//            System.out.print(text.split(";")[i] + "\n");
//        }
//        return "";
//    }
//
//    public static List<String> parsecate(String text, String text1) {
//        JSONArray jsonArray = JSON.parseArray(text.replace(";", "").split("=")[1]);
//        Map<String, String> map = new HashMap<String, String>();
//        Map<String, Set<String>> map1 = new HashMap<String, Set<String>>();
//        list = new ArrayList<String>();
//        Set<String> set = new HashSet<String>();
//        List<String> list = new ArrayList<String>();
//        for (int i = 0; i < jsonArray.size(); i++) {
//            JSONObject jsonObject = (JSONObject) jsonArray.get(i);
//            String name = jsonObject.getString("name");
//            String id = jsonObject.getString("id");
//            String[] category = text1.split(";");
//            list.add(name + "=" + id);
//            System.out.print(i);
//            for (int j = 0; j < category.length; j++) {
//                StringBuffer sb = new StringBuffer();
//                if (category[j].indexOf("category[" + id) != -1) {
////                    System.out.print(category[j]);
////                    map.put(name + "-" + id, category[j].split("=")[1]);
//                    JSONArray jsonArray1 = JSON.parseArray(category[j].split("=")[1]);
//                    for (int k = 0; k < jsonArray1.size(); k++) {
//                        JSONObject jsonObject1 = (JSONObject) jsonArray1.get(k);
//                        String name1 = jsonObject1.getString("name");
//                        String id1 = jsonObject1.getString("id");
////                        System.out.print(name+"="+id+"/"+name1+"="+id1+"\n");
////                            System.out.print(name1+"=="+id1);
//                        list.add(name+"="+id+"~"+name1+"="+id1);
////                        System.out.print(name+"="+id+"~"+name1+"="+id1+"\n");
////                            map.put(name + "=" + id+"/"+k, name1+"="+id1);
//
//                    }
////                    System.out.print(category[j].split("=")[1]+"\n");as
//                }
//
//            }
//        }
//        return list;
//    }
//
//    public static List<String> parsecate2(List<String> list,String text){
//        for (int i = 0;i<list.size();i++){
//            String[] category = text.split(";");
//            for (int j = 0; j < category.length; j++) {
////                String categoryName = list.get(i).split("~")[1].split("=")[0];
////                String categoryId = list.get(i).split("~")[1].split("=")[1];
//                if(list.get(i).indexOf("~") != -1 && list.get(i).indexOf("=") != -1 && category[j].indexOf("category[" + list.get(i).split("~")[1].split("=")[1]) != -1){
//                    JSONArray jsonArray1 = JSON.parseArray(category[j].split("=")[1]);
//                    for (int l = 0; l < jsonArray1.size(); l++) {
//                        JSONObject jsonObject = (JSONObject) jsonArray1.get(l);
//                        String name = jsonObject.getString("name");
//                        String id = jsonObject.getString("id");
////                        JSONArray jsonArray2 = JSON.parseArray(category[j].split("=")[1]);
////                        for (int k = 0; k < jsonArray2.size(); k++) {
////                            JSONObject jsonObject1 = (JSONObject) jsonArray2.get(k);
////                            String name1 = jsonObject1.getString("name");
////                            String id1 = jsonObject1.getString("id");
////                        System.out.print(list.get(i).split("=")[1]+"\n");
//                        System.out.print(list.get(i).split("~")[0].split("=")[0]+"="+list.get(i).split("~")[0].split("=")[1]+"~"+list.get(i).split("~")[1].split("=")[0]+"="+list.get(i).split("~")[1].split("=")[1]+"~"+name+"="+id+";\n");
////                        }
//                    }
//                }
//            }
////            System.out.print(list.get(i)+"\n");
//        }
//        return  null;
//    }
//
//
////    public static Map<String, String> parsecate1(Map<String, String> map, String text) {
////        Map<String, Map<String, String>> map1 = new HashMap<String, Map<String, String>>();
////        Map<String, String> map2 = new HashMap<String, String>();
//////        System.out.print(map);
////        for (Map.Entry<String, String> entry : map.entrySet()) {
////            String[] category = text.split(";");
////            for (int j = 0; j < category.length; j++) {
////                if (category[j].indexOf("category[" + entry.getValue().split("=")[1]) != -1) {
////                    JSONArray jsonArray1 = JSON.parseArray(category[j].split("=")[1]);
////                    for (int l = 0; l < jsonArray1.size(); l++) {
////                        JSONObject jsonObject = (JSONObject) jsonArray1.get(l);
////                        String name = jsonObject.getString("name");
////                        String id = jsonObject.getString("id");
////                        JSONArray jsonArray2 = JSON.parseArray(category[j].split("=")[1]);
////                        for (int k = 0; k < jsonArray2.size(); k++) {
////                            JSONObject jsonObject1 = (JSONObject) jsonArray2.get(k);
////                            String name1 = jsonObject1.getString("name");
////                            String id1 = jsonObject1.getString("id");
//////                        System.out.print(name1+"="+id1);
////                            map2.put(entry.getValue().split("=")[0] + "=" + entry.getValue().split("=")[1]+"/"+k, name1+"="+id1);
////                        }
//////                        System.out.print(map2);
////                    }
////
////                }
////            }
////
////
////        }
////
////        return map2;
////    }
//
//    public static void getExport(Map<String,String> map){
//        StringBuffer sb = new StringBuffer();
//        for(Map.Entry<String,String> entry:map.entrySet()){
//            sb.append(entry.getKey()+"/"+entry.getValue()+"\n");
//        }
////        System.out.print(sb.toString());
//    }
//
//    public static String getExcel(Map<String, String> map1, Map<String, String> map2) {
//        HSSFWorkbook wb = new HSSFWorkbook();
//        HSSFSheet sheet = wb.createSheet("sheet1");
//
//        // 设置excel每列宽度
//        sheet.setColumnWidth(0, 4000);
//        sheet.setColumnWidth(1, 3500);
//        // 创建字体样式
//        HSSFFont fonts = wb.createFont();
//        fonts.setFontName("Verdana");
//        fonts.setBoldweight((short) 100);
//        fonts.setFontHeight((short) 300);
//
//        // 创建单元格样式
//        HSSFCellStyle style = wb.createCellStyle();
//        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
//        style.setFillForegroundColor(HSSFColor.LIGHT_TURQUOISE.index);
//        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
//
//
//        style.setFont(fonts);// 设置字体
//        // 创建Excel的sheet的一行
//        HSSFRow row = null;
//        HSSFCell cell = null;
////        sheet.addMergedRegion(new re)
////        for(int i = 0;i<1000;i++){
////            row = sheet.createRow(i);
//        for (int j = 0; j < list.size(); j++) {
//            row = sheet.createRow(j);
//            cell = row.createCell(0);
//            cell.setCellValue(list.get(j));
//            for (int k = 0; k < list1.size(); k++) {
//                row = sheet.createRow(k);
//                row.createCell(2).setCellValue(list1.get(k));
//            }
//        }
////        }
//        try {
//            FileOutputStream os = new FileOutputStream("/home/randy/文档/category.xlsx");
//            wb.write(os);
//            os.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        return "";
//    }
//}
